﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace FPTPages.GalerryPage
{
    public partial class GalerryPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public string GenerateVideo()
        {
            string str = "";
            StringBuilder builder = new StringBuilder();
            string sql = "select * from videoLinks";
            string url = ConfigurationManager.ConnectionStrings["SqlProviderCon"].ToString();
            DataSet ds = new DataSet();

            using (SqlConnection con = new SqlConnection(url))
            {
                using (SqlDataAdapter da = new SqlDataAdapter(sql, con))
                {
                    da.Fill(ds);
                }
            }

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                builder.Append(@"<a href=""" + item[1].ToString() + @" ""> <img src="""
                    + item[2].ToString() + @" "" title=""" + item[3].ToString() + @"""/></a>" + "\n");
            }
            str = builder.ToString();
            return str;

        }

        public string GenerateImage()
        {
            string str = "";
            StringBuilder builder = new StringBuilder();
            string sql = "select * from images";
            string url = ConfigurationManager.ConnectionStrings["SqlProviderCon"].ToString();
            DataSet ds = new DataSet();

            using (SqlConnection con = new SqlConnection(url))
            {
                using (SqlDataAdapter da = new SqlDataAdapter(sql, con))
                {
                    da.Fill(ds);
                }
            }

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                builder.Append(@"<img src=""" + item[2].ToString() + @""" alt="""
                    + item[1].ToString() + @"""/>");
            }
            str = builder.ToString();
            return str;

        }

    }
}